<template>
	<view>
		<view class="foot-top">我的钱包</view>
		<view class="content">
			<view class="rest">
				<view class="balance" >
					<view class="title">账户余额</view>
					<view class="money">
						<view class="dollor">￥</view>
						<view class="num">{{money}}</view>
					</view>
					<view class="detail">余额明细</view>
				</view>
				<view class="buttons">
					<view class="recharge" @tap="toRechargePage">充值</view>
					<view class="withdrawal" @tap="toWithdrawalPage">提现</view>
				</view>
				<view class="guarantee">
					<view class="name">中国人保财险</view>
					<view class="asure">保障资金安全</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script module="wxs" lang="wxs" src="../../wxs/index.wxs"></script>
<script>
const http = require('../../utils/http.js')
const util = require('../../utils/util')
export default{
	data() {
	  return {
			userId: 0,
			money: "10000.10"
	  }
	},
  onLoad: function(options) {
		if (options.userId) {
			this.userId = options.userId;
		}
  },
  onShow: function() {
		this.getBalance();
  },
	methods: {
		getBalance() {
      uni.showLoading()
		  const params = {
		    url: '/mall4cloud_user/m/userBalance/get',
		    method: 'GET',
		    data: {
					userId: this.userId
				},
		    callBack: res => {
					this.money = res.balance.toString();
					uni.hideLoading()
		    }
		  }
		  http.request(params)
		},
		toRechargePage() {
		  uni.navigateTo({
		    // url: '/pages/recharge/recharge'
		    url: '/pages/recharge/recharge?userId=' + this.userId
		  })
		},
		toWithdrawalPage() {
		  uni.navigateTo({
		    // url: '/pages/withdrawal/withdrawal'
		    url: '/pages/withdrawal/withdrawal?userId=' + this.userId
		  })
		}
	}
}
</script>

<style>
@import './balance.css';
</style>